<?php

namespace app\common\validate;

use think\Validate;
use think\Db;

class Product extends Validate {
    
    protected $rule = [
        'supplier_id' => 'require',
        'user_id' => 'require'
    ];
    
    protected $message = [
        'supplier_id.require' => '获取不到商家信息',
        'user_id.require' => '登录失效'
    ];
    
    protected $snece = [
        'delivery_time' => ['supplier_id','user_id']
    ];
    
    protected function checkSupplier($id){
        $ok = Db::name('supplier')->where(['id'=>$id])->count();
        return $ok ? true : '商家不存在';
    }
    
    protected function checkUser($id){
        $ok = Db::name('user')->where(['id'=>$id])->count();
        return $ok ? true : '用户不存在';
    }
} 

